<template>
	<view @tap="handelClick" class="price-commodity__-content">
		<view class="image-content">
			<image :src="src ? src : defimg" mode="aspectFill"></image>
		</view>
		<!-- <view class="center-bg"></view> -->
		<view class="body">
			<view class="describe">{{describe}}</view>
			<view class="price-change" v-if="type == 1">
				<view class="price price-type"><i class="iconfont iconjifen"></i><text>{{price}}积分</text></view>
				<view class="change">已兑换{{change}}件</view>
			</view>
			<view class="price-change" v-else>
				<view class="price">￥{{price}}</view>
				<view class="change">销量{{change}}件</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			// 商品Id，外部点击后返回该id
			id: {
				type: [String, Number],
				default: ''
			},
			// 商品主图链接
			src: {
				type: String,
				default: ''
			},
			// 商品描述
			describe: {
				type: String,
				default: ''
			},
			// 商品积分
			price: {
				type: [String, Number],
				default: 0
			},
			// 已兑换数量
			change: {
				type: [String, Number],
				default: 0
			},
			// 类型
			type: {
				type: [String, Number],
				default: 0
			}
		},
		methods: {
			handelClick(e) {
				this.$emit('event', this.id)
			}
		}
	}
</script>

<style lang="scss" scoped>
	// 积分商品展示
	.price-commodity__-content {
		overflow: hidden;
		box-shadow: 0px 0px 12upx rgba(0, 0, 0, 0.1);
		margin-top: 20upx;
		border-radius: 10upx;

		.image-content {
			height: 350upx;
			background-color: #CFE8F1;
			border-radius: 10upx 10upx 0upx 0upx;

			image {
				border-radius: 10upx 10upx 0upx 0upx;
				width: 100%;
				height: 100%;
			}
		}

		.center-bg {
			width: 100%;
			height: 56upx;
			background-color: #F6F2EA;
		}

		.body {
			padding: 20upx;
			padding-bottom: 26upx;

			.describe {
				width: 100%;
				color: #333333;
				font-size: 26upx;
				height: 76upx;
				line-height: 38upx;
				overflow: hidden; //将超出的部分隐藏
				text-overflow: ellipsis; //超出部分用省略号显示
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
			}

			.price-change {
				display: flex;
				align-items: center;
				justify-content: space-between;
				flex-wrap: wrap;
				margin-top: 20upx;

				.price {
					color: #E43841;
					margin: 10upx 0;
					display: flex;
					font-size: 28upx;
					font-weight: bold;
					display: flex;
					align-items: center;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					text {
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}

				.change {
					color: #999999;
					font-size: 18upx;
					margin-left: auto;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				.price-type {
					color: #E48D04;

					i {
						font-size: 36upx;
					}
				}
			}
		}
	}
</style>
